import request from '@/utils/request'
// 进入内容管理,请求文章列表数据
export function reqGetArticles (params = {}) {
  return request({
    url: '/mp/v1_0/articles',
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
    params
  })
}
// 进入内容管理,请求文章频道数据
export function reqGetChannel () {
  return request({
    url: '/mp/v1_0/channels',
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
// 点击删除按钮,删除文章
export function reqDelArticle (id) {
  return request({
    url: '/mp/v1_0/articles/' + id,
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    }
  })
}
// 发送请求,发布文章
export function reqAddArticles (isDraft, formData) {
  return request({
    url: '/mp/v1_0/articles',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    params: {
      draft: isDraft
    },
    data: formData
  })
}
// 根据id获取指定文章
export function reqGetArticleById (id) {
  return request({
    url: '/mp/v1_0/articles/' + id,
    methods: 'GET'
  })
}
// 编辑文章,发送请求
export function reqEditArticle (id, isDraft, data) {
  return request({
    url: `/mp/v1_0/articles/${id}`,
    methods: 'PUT',
    params: {
      draft: isDraft
    },
    data
  })
}
// 进入评论管理,请求评论列表数据
export function reqComments (params = {}) {
  return request({
    url: '/mp/v1_0/articles',
    method: 'GET',
    params
  })
}
